﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NUnit.Mocks;
using Rhino.Mocks;
using Rhino.Mocks.Constraints;
using Rhino.Mocks.Impl;
using Rhino.Mocks.Interfaces;
using RoboZip;

namespace RoboZip.Test
{
    [TestFixture]
    class RoboZipCoreTest
    {
        private RoboZipCore roboZipCore = null;

        [SetUp]
        public void Setup()
        {
            roboZipCore = new RoboZipCore();
        }

        [TearDown]
        public void Teardown()
        {
            roboZipCore = null;
        }

        [Test]
        public void RoboZipCore_Parse0Arguments_ReturnsJobCountEqualsZero()
        {
            String[] jobArguments = new String[] {};
            roboZipCore.CreateJob(jobArguments);
            Assert.That(0, NUnit.Framework.Is.EqualTo(roboZipCore.JobCount));
        }

        [Test]
        public void RoboZipCore_Parse1ValidArgument_ReturnsJobCountEqualsZero()
        {
            String[] jobArguments = new String[] {@"C:\tmp"};
            roboZipCore.CreateJob(jobArguments);
            Assert.That(0, NUnit.Framework.Is.EqualTo(roboZipCore.JobCount));
        }

        [Test]
        public void RoboZipCore_Parse2ValidArguments_ReturnsJobCountEquals1()
        {
            String[] jobArguments = new String[] { @"C:\tmp" , @"D:\abc" };
            roboZipCore.CreateJob(jobArguments);
            Assert.That(1, NUnit.Framework.Is.EqualTo(roboZipCore.JobCount));
        }

        [Test]
        public void RoboZipCore_Add1ValidAnd1InvalidJob_ReturnsJobCountEquals1()
        {
            String[] jobArguments_1 = new String[] { @"C:\tmp", @"D:\abc" };
            String[] jobArguments_2 = new String[] { @"C:\tmp", @"D:>def" };
            roboZipCore.CreateJob(jobArguments_1);
            roboZipCore.CreateJob(jobArguments_2);
            Assert.That(1, NUnit.Framework.Is.EqualTo(roboZipCore.JobCount));
        }

        [Test]
        public void WiteJobProperties_WritesAllJobProperties()
        {
            List<String> fileList = new List<String>();
            fileList.Add("*.abc");
            fileList.Add("*.def");
            Job job = new Job();
            job.SourcePath = @"C:\tmp";
            job.DestinationPath = @"D:\abc";
            job.FileList = fileList;
            job.FileNamePattern = "'yyyy' - 'mm'";
            job.Start = new DateTime(2012,01,01);
            job.MonitoringPeriod = MonitoringPeriod.a;
            job.UpdateDestination = true;
            job.DeleteSource = false;
            roboZipCore.WiteJobProperties(job);
        }


    }
}
